<%@ include file="/WEB-INF/pages/common/taglibs.jsp" %>
<script type="text/javascript">
    function changePassword() {
        var currentForm = document.forms["changePasswordForm"];
        currentForm.elements["userModel.userName"].value=currentForm.elements["userModel.userName"].value.trim();
        currentForm.elements["userModel.userPassword"].value=currentForm.elements["userModel.userPassword"].value.trim();
        currentForm.elements["userModel.newPassword"].value=currentForm.elements["userModel.newPassword"].value.trim();
        currentForm.elements["userModel.confirmPassword"].value=currentForm.elements["userModel.confirmPassword"].value.trim();        
        var userName=currentForm.elements["userModel.userName"];
        var userPassword=currentForm.elements["userModel.userPassword"];
        var newPassword=currentForm.elements["userModel.newPassword"];        
        var confirmPassword=currentForm.elements["userModel.confirmPassword"];        
        if(isEmpty(userName.value)){
        	  alert('<s:text name="label.user.required"/>');
            return;
        }
        if(isEmpty(userPassword.value)){
            alert('<s:text name="label.old.password.empty"/>');
            return;
        }
        if(isEmpty(newPassword.value)){
            alert('<s:text name="label.new.password.empty"/>');
            return;
        }
        if(isEmpty(confirmPassword.value)){
            alert('<s:text name="label.confirm.password.empty"/>');
            return;
        }
        if(currentForm.elements["userModel.newPassword"].value!=currentForm.elements["userModel.confirmPassword"].value){
            alert('<s:text name="label.new.password.different"/>');
            return;
        }
        submitForm("changePasswordForm", "changePassword.action");
    }

    function cancelChangePassword() {
        submitForm("changePasswordForm", "cancelChangePassword.action");
    }    
</script>

<s:form name="changePasswordForm" action="" >
    <table align="center" cellpadding="0" cellspacing="0" class="body_content full_width">
        <tr>
            <td align="left" valign="bottom" class="main_page_content_icon" width="4%">
                <img src='<c:url value="/images/body-icon_check.gif"/>' width="29" height="44">
            </td>
            <td valign="bottom" class="page_title_bg" width="96%">
                <span class="page_title">
                    <s:text name="label.change.password"/>
                </span>
            </td>
        </tr>
        <tr>
            <td class="subcontent" colspan="2">&nbsp;</td>
        </tr>
    </table>

    <table border="0" align="center" cellpadding="0" cellspacing="0" class="body_content full_width bordered">
       <tr class="even">
            <td colspan="3" class="form_label_padded" align="left">
                    <li><s:text name="label.mandatory"/></li>
            </td>
        </tr>
        <tr class="odd">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.userName"/><font color="red">*</font></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:textfield name="userModel.userName" maxLength="30" cssStyle="width:120px"/>
            </td>
        </tr>
        <tr class="even">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.old.password"/><font color="red">*</font></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:password name="userModel.userPassword" maxlength="30" cssStyle="width:120px"/>
            </td>
        </tr>
        <tr class="odd">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.new.password"/><font color="red">*</font></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:password name="userModel.newPassword" maxLength="30" cssStyle="width:120px"/>
            </td>
        </tr>
        <tr class="even">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.confirm.password"/><font color="red">*</font></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:password name="userModel.confirmPassword" maxLength="30" cssStyle="width:120px"/>
            </td>
        </tr>
        <tr class="odd">
            <td class="txtData" colspan="3">
                <input type="button" class="button" value="<s:text name='label.save'/>" onclick="changePassword();">
                <input type="button" class="button" value="<s:text name='label.back'/>" onclick="cancelChangePassword();">
            </td>
        </tr>
    </table>
</s:form>



